import * as api from '../axios';
import * as util from "@/common/util";

export default {
  //机柜列表
  getStationList: (params, page) => {
    const url = util.replacePageNumAndSize(`/manage/cabinets/{pageNum}/{pageSize}`, page)
    return api.axiosGetAPI(url, params);
  },
  //刷新电量
  stationRefresh: cabinetNo => {
    const headers = {
      'lang-key': 'Station_refreshBattery'
    }
    return api.axiosPostAPI(`/manage/cabinets/${cabinetNo}/refresh-battery`, '', headers);
  },
  //一键全弹
  stationEjectAll: cabinetNo => {
    const headers = {
      'lang-key': 'Station_Ejectall'
    }
    return api.axiosPostAPI(`/manage/cabinets/${cabinetNo}/eject-all`, '', headers);
  },
  //锁定或开启
  stationLock: params => {
    const headers = {
      'lang-key': params.customizeState == 2 ?
        'Station_LockStatus_Lock' : 'Station_List_Unlock'
    }
    return api.axiosPutAPI(`/manage/cabinets/${params.cabinetNo}/customize-state?customizeState=${params.customizeState}`, '', headers);
  },
  //删除小机柜
  delCabinet: id => {
    const headers = {
      'lang-key': 'delete'
    }
    return api.axiosDeleteAPI(`/manage/cabinets/${id}`, '', headers);
  },
  //设备运营列表
  operationList: (params, page) => {
    const url = util.replacePageNumAndSize('/manage/cabinets/operation/{pageNum}/{pageSize}', page)
    return api.axiosGetAPI(url, params);
  },
  //获取机柜导入模板
  getTemplate: () => {
    return api.axiosGetAPI('/manage/cabinets/export', null, null, {
      responseType: 'blob'
    })
  },

  //获取下拉代理
  getAgent: () => {
    return api.axiosGetAPI('/manage/cabinets/bindings/transfer-agents')
  },

  //获取下拉网点
  getShop: () => {
    return api.axiosGetAPI('/manage/cabinets/bindings/transfer-branches')
  },

  //机柜绑定到代理-网点
  bindingType: params => {
    const headers = {
      'lang-key': 'Assign_station'
    }
    return api.axiosPutAPI('/manage/cabinets/bindings', params, headers);
  },

  //回收机柜
  recycleStation: params => {
    const headers = {
      'lang-key': 'Recycle_to_inventory'
    }
    return api.axiosPutAPI('/manage/cabinets/recoveries', params, headers);
  },

  //获取机柜详情
  getStationDtail: cabinetNo => {
    return api.axiosGetAPI(`/manage/cabinets/${cabinetNo}`)
  },

  //初始化充电宝
  initializePower: id => {
    const headers = {
      'lang-key': 'initialize'
    }
    return api.axiosPutAPI(`/manage/power-banks/${id}/init`, '', headers);
  },

  //刷新充电宝
  refreshPower: params => {
    const headers = {
      'lang-key': 'Station_refreshBattery'
    }
    return api.axiosGetAPI(`/manage/power-banks/refresh-powerBank`, params, headers);
  },

  //弹出充电宝
  ejectPower: params => {
    const headers = {
      'lang-key': 'Station_eject'
    }
    return api.axiosPostAPI(`/manage/cabinets/${params.cabinetNo}/eject`, params, headers);
  },

  //充电宝列表
  getPowerList: (params, page) => {
    const url = util.replacePageNumAndSize(`/manage/power-banks/{pageNum}/{pageSize}`, page)
    return api.axiosGetAPI(url, params);
  },

  //获取充电宝导入模板
  getPowerTemplate: () => {
    return api.axiosGetAPI('/manage/power-banks/export/template', null, null, {
      responseType: 'blob'
    })
  },

  //获取充电宝详情
  getPowerDetail: id => {
    return api.axiosGetAPI(`/manage/power-banks/${id}`)
  },

  //获取累计充电电量
  getPowerTotalCharge: (pbNo, rangeTime) => {
    return api.axiosGetAPI(`/manage/power-banks/charts/over-charge?pbNo=${pbNo}&rangeTime=${rangeTime}`)
  },

  //获取温度数据
  getPowerTemp: (pbNo, rangeTime) => {
    return api.axiosGetAPI(`/manage/power-banks/charts/temperature?pbNo=${pbNo}&rangeTime=${rangeTime}`)
  },

  //获取电流数据
  getPowerCurrent: (pbNo, rangeTime) => {
    return api.axiosGetAPI(`/manage/power-banks/charts/current?pbNo=${pbNo}&rangeTime=${rangeTime}`)
  },

  //获取电压数据
  getPowerVoltage: (pbNo, rangeTime) => {
    return api.axiosGetAPI(`/manage/power-banks/charts/voltage?pbNo=${pbNo}&rangeTime=${rangeTime}`)
  },

  //获取带屏设备选项
  getStationScreen: (params, page) => {
    const url = util.replacePageNumAndSize(`/manage/cabinets/player/{pageNum}/{pageSize}`, page)
    return api.axiosGetAPI(url, params);
  },

  //获取WiFi配置
  getWifiConfig: cabinetNo => {
    return api.axiosGetAPI(`/manage/cabinets/getWifiConfigBycabinetNo?cabinetNo=${cabinetNo}`)
  },


  //保存WiFi配置
  saveWifiConfig: params => {
    return api.axiosPutAPI(`/manage/cabinets/saveWifiConfig?cabinetNo=${params.cabinetNo}&password=${params.password}&ssid=${params.ssid}`, params);
  },

  //重置wifi
  resetWifiConfig: cabinetNo => {
    return api.axiosPutAPI(`/manage/cabinets/factoryWifi?cabinetNo=${cabinetNo}`);
  },

  //重启机柜
  resetStations: id => {
    return api.axiosPostAPI(`/manage/cabinets/cabinet/restart?id=${id}`);
  },  

  //设置音量
  setVolume: (cabinetNo,volume) => {
    return api.axiosPutAPI(`/manage/cabinets/volume?cabinetNo=${cabinetNo}&volume=${volume}`);
  },

};